# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Calculator.t'

#########################

# change 'tests => 1' to 'tests => last_test_to_print';

use Test::More tests => 6;
BEGIN { use_ok('Calculator');
        use_ok('Calculator::PostfixCalc');
};

#########################

# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.


my $input = 'b = a = 4*2';
my $expected = '4 2 * a = b =';
my $tree = parse($input);
is($tree->ceval(),$expected,"asignacion encadenada");


$input = 'c = { a = 4; b = 2*a }';
$expected = '4 a = ; 2 a * b = c =';
$tree = parse($input);
is($tree->ceval(),$expected,"asignacion de un bloque");


$input = 'a = b+2 > c*4';
$expected = 'b 2 + c 4 * > a =';
$tree = parse($input);
is($tree->ceval(),$expected,"operaciones relacionales");

$input = 'if (a > 0) then if (b > 0) then {5} else {6}';
$expected = 'a 0 > jz else1 b 0 > jz else2 5 j endif3 :else2 6 :endif3  :else1 ';
$tree = parse($input);
is($tree->ceval(),$expected,"ambiguedad del if");